require 'helpers/basic_helper'
module Paperclip
  class HashieMashAdapter < AbstractAdapter

    def initialize(target)
      self.original_filename = target.filename
      @tempfile = copy_to_tempfile(target.tempfile)
      @content_type = ContentTypeDetector.new(@tempfile.path).detect
      @size = @tempfile.size
    end

  end
end

Paperclip.io_adapters.register Paperclip::HashieMashAdapter do |target|
  target.class.name.include?("Hashie::Mash")
end
class Entry < Grape::API
  format :json
  default_format :json

  prefix :api

  helpers ::BasicHelper

  # rescue_from :all do |e|
  #   GeneralLog.write :error, "#{e.message}:#{e.backtrace}"
  #   begin
  #     req = Rack::Request.new(env)
  #     Debug.create(message: e.message, backtrace: e.backtrace, ip: req.ip, source: req.user_agent)
  #   rescue => ex
  #     GeneralLog.write :error, "#{ex.message}:#{ex.backtrace}"
  #   end
  #   error!({error_description: '服务器忙，请稍后再试。'}, 500)
  # end

  rescue_from Grape::Exceptions::ValidationErrors do |e|
    error!({error_description: e.full_messages}, 400)
  end

  # mount ::V1::LawRecords
  # mount ::V1::Orders
  # mount ::V1::Users
  mount ::V1::Homes
  add_swagger_documentation\
    specific_api_documentation: {desc: ''}
end